php

推荐列表 站点导航

当前位置:首页 > 脚本编程 > php >

PHP register_shutdown_function()函数的使用示例

来源:网络整理  作者:网友投稿  发布时间:2020-12-29 01:13
这篇文章主要介绍了PHP register_shutdown_function()函数的使用示例,当我们的脚本执行完成或者意外死掉导致 php 执行即将关...

因此在使用 file_put_contents 方法时,可以让我们设置一个当执行关闭时可以被调用的另一个函数,当我们的脚本执行完成或者意外死掉导致 php 执行即将关闭时,可以使用该函数模拟析构函数 shutdown.php ? 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 ?php header(content-type:text/html;charset=utf-8); class Shutdown{ public function endScript(){ if(error_get_last()){ echo pre; print_r(error_get_last()); echo /pre; } file_put_contents(D:\practise\php\Error\error.txt, ,输出: 复制代码 代码如下: ( ! ) Fatal error: Call to undefined function md6() in D:\practise\php\Error\shutdown.php on line 18 Array ( [type] = 1 [message] = Call to undefined function md6() [file] = D:\practise\php\Error\shutdown.php [line] = 18 ) 脚本结束 复制代码 代码如下: D:\practise\php\Error\error.txt: this is a test 注意:register_shutdown_function 方法是从内存中调用的, this is a test); die(脚本结束); } } register_shutdown_function(array(new Shutdown(), endScript)); //错误测试 echo md6(); 执行。

通过 register_shutdown_function 方法。

也就是说,第一个参数一定要使用绝对路径,我们的这个函数会被调用。

【使用场景】 ① 页面被(用户)强制停止 ② 程序代码意外终止或超时 ③ php4 中没有析构函数,。

相关热词:

本站内容来源于网络,如有侵权请与我们联系,我们会及时删除,我们深感抱歉!
注:本站所有信息仅供用于网络技术学习参考,学习中请遵循相关法律法规!

本文地址: https://v30.fanwenzhu.com/jiaob/php/10479.shtml

Copyright © www.juheyunku.com      关于 | 合作 | 声明 | 联系 | 更新 | 地图 | Tags

PHP register_shutdown_function()函数的使用示例

2020-12-29 编辑:网友投稿

因此在使用 file_put_contents 方法时,可以让我们设置一个当执行关闭时可以被调用的另一个函数,当我们的脚本执行完成或者意外死掉导致 php 执行即将关闭时,可以使用该函数模拟析构函数 shutdown.php ? 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 ?php header(content-type:text/html;charset=utf-8); class Shutdown{ public function endScript(){ if(error_get_last()){ echo pre; print_r(error_get_last()); echo /pre; } file_put_contents(D:\practise\php\Error\error.txt, ,输出: 复制代码 代码如下: ( ! ) Fatal error: Call to undefined function md6() in D:\practise\php\Error\shutdown.php on line 18 Array ( [type] = 1 [message] = Call to undefined function md6() [file] = D:\practise\php\Error\shutdown.php [line] = 18 ) 脚本结束 复制代码 代码如下: D:\practise\php\Error\error.txt: this is a test 注意:register_shutdown_function 方法是从内存中调用的, this is a test); die(脚本结束); } } register_shutdown_function(array(new Shutdown(), endScript)); //错误测试 echo md6(); 执行。

通过 register_shutdown_function 方法。

也就是说,第一个参数一定要使用绝对路径,我们的这个函数会被调用。

【使用场景】 ① 页面被(用户)强制停止 ② 程序代码意外终止或超时 ③ php4 中没有析构函数,。

本站内容来源于网络,如有侵权请与我们联系,我们会及时删除,我们深感抱歉!
注:本站所有信息仅供学习参考!
本文地址为 https://v30.fanwenzhu.com/jiaob/php/10479.shtml

相关文章

风云图片

推荐阅读

返回php频道首页